package com.qf.boot220302.exhandler;

import com.baomidou.kaptcha.exception.KaptchaIncorrectException;
import com.qf.boot220302.vo.ResultVo;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器
 */
@RestControllerAdvice
public class GlobalExHandler {

    @ExceptionHandler(KaptchaIncorrectException.class)
    public ResultVo handleKapcharIncorectEx(KaptchaIncorrectException ex){

        return ResultVo.error("验证码错误");

    }

    @ExceptionHandler(Exception.class)
    public ResultVo handlEx(Exception ex){

        final String message = ex.getMessage();
        return ResultVo.error(message);

    }

}
